<?php

namespace app\modules\admin\assets;

use yii\web\AssetBundle;

/**
 * Wecaht Member Center front-end assets
 */
class AdminAsset extends AssetBundle
{
    public $basePath = '@webroot/wechat';
    public $baseUrl = '@web/wechat';
    public $css = [
        '../base/css/site.css',
    ];
    
    public $js = [
        // '@bower-asset/bootstrap/dist/js/bootstrap.js',  
    ];
   
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
    ];

    public function init()
    {        
        if (\yii::$app->params['editorConfig']['on']) // 如果开启了使用富文本
        {    
            if (\yii::$app->params['editorConfig']['type'] === 'mdeditor') { // 加载md-editor 相关css, js文件                
                array_push($this->css, '../member/mdeditor/css/editormd.css');
                array_push($this->js, '../member/mdeditor/editormd.js');
                array_push($this->js, '../member/mdeditor/init.js');
            } elseif (\yii::$app->params['editorConfig']['type'] === 'ueditor') { // 加载 u-editor 相关文件
                array_push($this->js, '../member/ueditor/ueditor.config.js');
                array_push($this->js, '../member/ueditor/ueditor.all.min.js');
                array_push($this->js, '../member/ueditor/ueditor.init.js');
            }

        }
    }
}
